/**
 * Created by IntelliJ IDEA.
 * User: user
 * Date: 11.07.12
 * Time: 16:37
 * To change this template use File | Settings | File Templates.
 */
package zakladki.AS3.widok {
import AS3.constants.combo.HouseHeatingSource;
import AS3.constants.combo.HouseMaterial;
import AS3.constants.combo.HouseType;

public class HouseViewChangeListener {

    private var houseContentPane:Miesz;

    public function HouseViewChangeListener(houseContentPane:Miesz) {
        this.houseContentPane = houseContentPane;
    }

    public function houseTempChanged(houseType:int, heating:int):void {

        houseContentPane.dom_termometr.visible = false;
        houseContentPane.blok_temperatura.visible = false;

        if (houseType == HouseType.DETACHED || houseType == HouseType.TERRACE) {
            houseContentPane.dom_termometr.visible = true;
            houseContentPane.dom_termometr.gotoAndStop(heating + 1);
        }
        else {
            houseContentPane.blok_temperatura.visible = true;
            houseContentPane.blok_temperatura.gotoAndStop(heating + 1);
        }
    }

    public function houseHeatingChanged(heatingSource:int, houseType:int):void {
        houseContentPane.elektrocieplownia.visible = false;
        houseContentPane.olejOpalowy.visible = false;
        houseContentPane.gaz.visible = false;
        houseContentPane.dymCzarny.visible = false;
        houseContentPane.dymSredni.visible = false;
        houseContentPane.wegiel.visible = false;
        houseContentPane.elektryczne.visible = false;
        houseContentPane.biomasa.visible = false;

        if (heatingSource == HouseHeatingSource.CENTRAL) {
            houseContentPane.elektrocieplownia.visible = true;
        }
        else if (heatingSource == HouseHeatingSource.OIL) {
            houseContentPane.olejOpalowy.visible = true;
        }
        else if (heatingSource == HouseHeatingSource.GAS) {
            houseContentPane.gaz.visible = true;
        }
        else if (heatingSource == HouseHeatingSource.COAL_OLD) {
            houseContentPane.wegiel.visible = true;
            if (houseType == HouseType.DETACHED || houseType == HouseType.TERRACE) {
                houseContentPane.dymCzarny.visible = true;
            }
        }
        else if (heatingSource == HouseHeatingSource.COAL_MODERN) {
            houseContentPane.wegiel.visible = true;
            if (houseType == HouseType.DETACHED || houseType == HouseType.TERRACE) {
                houseContentPane.dymSredni.visible = true;
            }
        }
        else if (heatingSource == HouseHeatingSource.ELECTRIC) {
            houseContentPane.elektryczne.visible = true;
        }
        else if (heatingSource == HouseHeatingSource.BIOMASS) {
            houseContentPane.biomasa.visible = true;
        }
    }

    public function houseHolderViewChanged(houseHolderCount:int, houseType:int):void {
        var people:Array = new Array();
        var i:int = new int(0);
        var peopleNumber:int = new int(0);
        if (houseHolderCount < 8) {
            peopleNumber = houseHolderCount;
        }
        else {
            peopleNumber = 7;
        }

        houseContentPane.blok_ludek_1.visible = false;
        houseContentPane.blok_ludek_2.visible = false;
        houseContentPane.blok_ludek_3.visible = false;
        houseContentPane.blok_ludek_4.visible = false;
        houseContentPane.blok_ludek_5.visible = false;
        houseContentPane.blok_ludek_6.visible = false;
        houseContentPane.blok_ludek_7.visible = false;

        houseContentPane.ludek1.visible = false;
        //Mies.ludek1.
        houseContentPane.ludek2.visible = false;
        houseContentPane.ludek3.visible = false;
        houseContentPane.ludek4.visible = false;
        houseContentPane.ludek5.visible = false;
        houseContentPane.ludek6.visible = false;
        houseContentPane.ludek7.visible = false;

        if (houseType == HouseType.DETACHED || houseType == HouseType.TERRACE) {

            if (peopleNumber == 1) {
                houseContentPane.ludek1.visible = true;
                houseContentPane.ludek1.gotoAndStop(1);

            }
            else if (peopleNumber == 2) {
                houseContentPane.ludek1.visible = true;
                houseContentPane.ludek1.gotoAndStop(2);
            }
            else if (peopleNumber > 2) {
                houseContentPane.ludek1.visible = true;
                houseContentPane.ludek1.gotoAndStop(2);

                people.push(houseContentPane.ludek3);
                people.push(houseContentPane.ludek4);
                people.push(houseContentPane.ludek5);
                people.push(houseContentPane.ludek6);
                people.push(houseContentPane.ludek7);

                for (i = 0; i < peopleNumber - 2; i++) {
                    people[i].visible = true;
                }
            }
        }
        else if (houseType == HouseType.MULTI_FAMILY) {
            people.push(houseContentPane.blok_ludek_1);
            people.push(houseContentPane.blok_ludek_2);
            people.push(houseContentPane.blok_ludek_3);
            people.push(houseContentPane.blok_ludek_4);
            people.push(houseContentPane.blok_ludek_5);
            people.push(houseContentPane.blok_ludek_6);
            people.push(houseContentPane.blok_ludek_7);

            for (i = 0; i < peopleNumber; i++) {
                people[i].visible = true;
            }
        }
    }

    public function houseTypeChanged(houseType:int, materialType:int):void {
        houseContentPane.blok.visible = false;
        houseContentPane.blok_cegly.visible = false;
        houseContentPane.szeregowiec_beton.visible = false;
        houseContentPane.szeregowiec_drewno.visible = false;
        houseContentPane.dom_Zdrewna.visible = false;
        houseContentPane.cegla.visible = false;

        if ((houseType == HouseType.DETACHED) && (materialType == HouseMaterial.CONCRETE)) {
        }
        else if ((houseType == HouseType.DETACHED) && (materialType == HouseMaterial.BRICK)) {
            houseContentPane.cegla.visible = true;
        }
        else if ((houseType == HouseType.DETACHED) && (materialType == HouseMaterial.WOOD)) {
            houseContentPane.dom_Zdrewna.visible = true;
        }
        else if ((houseType == HouseType.TERRACE) && (materialType == HouseMaterial.CONCRETE)) {
            houseContentPane.szeregowiec_beton.visible = true;
        }
        else if ((houseType == HouseType.TERRACE) && (materialType == HouseMaterial.BRICK)) {
            houseContentPane.szeregowiec_beton.visible = true;
            houseContentPane.cegla.visible = true;
        }
        else if ((houseType == HouseType.TERRACE) && (materialType == HouseMaterial.WOOD)) {
            houseContentPane.dom_Zdrewna.visible = true;
            houseContentPane.szeregowiec_drewno.visible = true;
        }
        else if ((houseType == HouseType.MULTI_FAMILY) && (materialType == HouseMaterial.CONCRETE)) {
            houseContentPane.blok.visible = true;
        }
        else if ((houseType == HouseType.MULTI_FAMILY) && (materialType == HouseMaterial.BRICK)) {
            houseContentPane.blok.visible = true;
            houseContentPane.blok_cegly.visible = true;
        }
        else if ((houseType == HouseType.MULTI_FAMILY) && (materialType == HouseMaterial.WOOD)) {
            houseContentPane.blok.visible = true;
        }
    }

    public function houseInsulationChanged(houseType:int, insulation:int):void {
        houseContentPane.ocieplenie.visible = false;
        houseContentPane.blok_ocieplenie.visible = false;
        if (houseType == HouseType.DETACHED || houseType == HouseType.TERRACE) {
            houseContentPane.ocieplenie.visible = true;
            houseContentPane.ocieplenie.gotoAndStop(insulation + 1);
        }
        else {
            houseContentPane.blok_ocieplenie.visible = true;
            houseContentPane.blok_ocieplenie.gotoAndStop(insulation + 1);
        }
    }





}
}
